<?php

namespace app\model\questionnaire;

use app\BaseModel;
use app\model\not_del\UserModel as NotDelUserModel;
use think\model\relation\BelongsTo;

/**
 * 问卷-任务用户
 */
class QuestionnaireTaskUserModel extends BaseModel
{
    protected $name = 'questionnaire_task_user';

    /**
     * 关联用户
     * @return BelongsTo
     */
    public function taskUser(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name' => 'name',
            'age',
            'sex',
            'department_id',
            'username',
            'id_card',
            'phone',
            'avatar',
            'user_number',
            'student_status'
        ]);
    }

    /**
     * 关联用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name' => 'name',
            'age',
            'sex',
            'department_id',
            'unit_name'
        ]);
    }

    /**
     * 关联用户
     * @return BelongsTo
     */
    public function user2(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name' => 'name',
            'age',
            'sex',
            'department_id'
        ]);
    }

    /**
     * 关联任务用户结果
     * @return BelongsTo
     */
    public function TaskUserResult(): BelongsTo
    {
        return $this->belongsTo(QuestionnaireTaskUserResultModel::class,'result_id')->bind([
            'result_time' => 'time',
            'result_total_score' => 'total_score',
            'is_comment'
        ]);
    }

    /**
     * 试卷
     * @return BelongsTo
     */
    public function paper(): BelongsTo
    {
        return $this->belongsTo(QuestionnairePaperModel::class,'paper_id')->bind([
            'paper_name' => 'name',
            'paper_topic_num' => 'topic_num',
            'paper_total_score' => 'total_score',
            'paper_time_limited' => 'time_limited',
            'paper_type_name' => 'type_name',
            'paper_instructions' => 'instructions',
        ]);
    }

    /**
     * 关联任务
     * @return BelongsTo
     */
    public function task(): BelongsTo
    {
        return $this->belongsTo(QuestionnaireTaskModel::class,'task_id')->bind([
            'task_name'=>'name',
            'task_is_time' => 'is_time',
            'task_start_time' => 'start_time',
            'task_end_time' => 'end_time',
            'result_read_auth',
        ]);
    }
}